/**
 *   
 * Copyright (c) 2010-2020 Founder Ltd. All Rights Reserved.   
 *   
 * This software is the confidential and proprietary information of   
 * Founder. You shall not disclose such Confidential Information   
 * and shall use it only in accordance with the terms of the agreements   
 * you entered into with Founder.   
 *   
 *
 * @Project android_api
 * @Package com.example.android_api.util
 * @Title Util.java
 * @Description 
 * @Author robinjiang
 * @Date 2013-10-31 下午3:37:04
 * @Version V1.0
 */
package com.example.android_api.util;

import java.io.File;

import android.os.Environment;

/**
 * 
 * @Project_Name android_api
 * @Type_Name Util
 * @Description
 * @Author robinjiang
 * @Date 2013-10-31 下午3:37:04
 * 
 * @Update_User robinjiang
 * @Update_Date 2013-10-31 下午3:37:04
 * @Update_Desprition
 * 
 * @Version V1.0
 */
public class Util {

	/**
	 * @Description
	 * @Author robinjiang
	 * @Date 2013-10-31 下午3:37:04
	 * 
	 * @Update_User robinjiang
	 * @Update_Date 2013-10-31 下午3:37:04
	 * @Update_Desprition
	 * 
	 */
	public Util() {
		// TODO Auto-generated constructor stub
	}

	/**
	 * 
	 * @Description 检查是否有SD卡
	 * @Author robinjiang
	 * @Date 2013-10-31 下午3:51:44
	 * 
	 * @Update_User robinjiang
	 * @Update_Date 2013-10-31 下午3:51:44
	 * @Update_Desprition
	 * 
	 * @return
	 * @return boolean
	 * @throws
	 */
	public static boolean isExternalStorageWritable() {
		String state = Environment.getExternalStorageState();
		if (Environment.MEDIA_MOUNTED.equals(state)) {
			return true;
		}
		return false;
	}

	/**
	 * 
	 * @Description 检查是否有可读SD卡
	 * @Author robinjiang
	 * @Date 2013-10-31 下午3:52:00
	 * 
	 * @Update_User robinjiang
	 * @Update_Date 2013-10-31 下午3:52:00
	 * @Update_Desprition
	 * 
	 * @return
	 * @return boolean
	 * @throws
	 */
	public static boolean isExternalStorageReadable() {
		String state = Environment.getExternalStorageState();
		if (Environment.MEDIA_MOUNTED.equals(state)
				|| Environment.MEDIA_MOUNTED_READ_ONLY.equals(state)) {
			return true;
		}
		return false;
	}

	/**
	 * 在SDka中创建指定类型指定名称的文件
	 * @Description    
	 * @Author robinjiang 
	 * @Date 2013-10-31 下午3:58:49 
	 *  
	 * @Update_User robinjiang   
	 * @Update_Date 2013-10-31 下午3:58:49   
	 * @Update_Desprition 
	 *
	 * @param albumName
	 * @param type   ：DIRECTORY_MUSIC or DIRECTORY_PICTURES.
	 * @return 
	 * @return File
	 * @throws
	 */
	public static File getAlbumStorageDir(String albumName, String type) {
		// Get the directory for the user's public pictures directory.
		File file = new File(
				Environment.getExternalStoragePublicDirectory(type), albumName);
		if (!file.mkdirs()) {
			return null;
		}
		return file;
	}
}
